package com.xiaoshuidi.cloud.framework.pay.core.client.impl.tongshangyun.enums;

import cn.hutool.core.lang.Assert;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

@AllArgsConstructor
@Getter
public enum TongshangyunApiType {
    /**
     * 消费申请
     */

    CONSUME_APPLY("allinpay.yunst.orderService.consumeApply"),

    /**
     * 订单状态查询
     */
    GET_ORDER_DETAIL("allinpay.yunst.orderService.getOrderDetail"),

    /**
     * 创建用户
     */
    CREATE_MEMBER("allinpay.yunst.memberService.createMember"),

    /**
     * 会员绑定支付账户用户标识
     */
    APPLY_BIND_ACCT("allinpay.yunst.memberService.applyBindAcct"),

    /**
     * 企业会员开户H5
     */
    ENTERPRISE_MEMBER_ACCOUNT_ESTABLISH("allinpay.yunst.memberService.registerCompanyMember"),

    /**
     * 提现申请
     */

    WITHDRAW_APPLY("allinpay.yunst.orderService.withdrawApply"),


    QUERY_BANK_CARD("allinpay.yunst.memberService.queryBankCard"),

    /**
     * 查询余额
     */
    QUERY_BALANCE("allinpay.yunst.orderService.queryBalance");

    private String api;


    public static TongshangyunApiType getEnumByApi(String api) {
        TongshangyunApiType apiEnum = Arrays.stream(TongshangyunApiType.values()).filter(p -> p.api.equals(api)).findFirst().orElse(null);
        Assert.isTrue(apiEnum != null, "TongshangyunApiType:{}不存在", api);
        return apiEnum;
    }
}
